package com.Controller;

import com.Service.SNService;
import com.Service.StuService;
import com.bean.stuMind;
import com.bean.student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/zl")
public class ZLController {

    @Autowired
    private StuService stuService;

    @Autowired
    private SNService snService;

    @RequestMapping("/insert")
    public String insertHtml(){
        return "zhuliAdd";
    }

    @RequestMapping("/add")
    public  String toAdd(student stu){
        stuService.save(stu);
        System.out.println("插入成功");
        return "redirect:/zl/insert";
    }

    @RequestMapping("/list")
    public String stuList (Model model){
        List<stuMind> lists= snService.listAll();
        model.addAttribute("lists",lists);
        return "studentList";
    }
}
